{extend name="public/base"}

{block name="title"}就行天下-店铺信息{/block}

{block name="style"}
<link rel="stylesheet" href="__STATIC__/home/css/personal.css" />
{js href="__STATIC__/home/css/jquery.jcrop.min.css" /}
<style>
    .weui-cells {
        margin-top: 0px;
    }
</style>
{/block}

{block name="main"}
<div class="pageControl">
    <div class="main-top"></div>
    <div class="msui_nav msui_navTop">
        <a class="msui_navTop-back" href="javascript:history.back();"><i class="micon-back"></i></a>
        <h1 class="msui_navTop-title">店铺信息</h1>
        <a href="" class="msui_navTop-right msui_navTop-cnav"><i class="micon-cnav"></i></a>
    </div>
    <a href="javascript:;" data-target="#camera" class="open-popup weui-cell radiusImg weui-cell_access">
        <div class="weui-cell__bd">
            <label class=" cl-3333">修改店铺logo</label>
        </div>
        <div class="weui-cell__ft">
            <img class="logo" src="{$data.logo}" style="margin-left: 7rem">
            <input class="uploaderInput weui-uploader__input" type="file" accept="image/*" data-field="logo" data-quantity="pic" data-model="shop" data-width="100" data-height="100"/>
            <input type="hidden" name="logo" value="{$data.logo|default=''}">
        </div>
    </a>
    <a href="javascript:;" data-target="#shopName" class="open-popup weui-cell weui-cell_access open-popup">
        <div class="weui-cell__bd">
            <label class=" cl-9999">店铺名称</label>
        </div>
        <div class="weui-cell__ft">
            <span class="fs065 cl-3333">{$data.name}</span>
        </div>
    </a>
    <a href="javascript:;" data-target="#amenSshopName" class="open-popup weui-cell weui-cell_access">
        <div class="weui-cell__hd">
            <label class=" cl-9999 weui-label">店铺地址</label>
        </div>
        <div class="weui-cell__bd text-right">
            <span class="fs065 cl-3333">{$data.address}</span>
        </div>
    </a>
    <a href="javascript:;" data-target="#businessItem"  class="weui-cell weui-cells weui-cell_access open-popup">
        <div class="weui-cell__bd">
            <label class=" cl-9999">经营项目</label>
        </div>
        <div class="weui-cell__ft">
            <span class="fs065 cl-3333">查看</span>
        </div>
    </a>
    <div class="weui-cells">
        <a href="javascript:;" data-target="#marginService" class="open-popup weui-cell weui-cell_access">
            <div class="weui-cell__bd">
                <label class="cl-9999">保证金保障服务</label>
            </div>
            <div class="weui-cell__ft">
                <span class="fs065 cl-3333">未开通</span>
            </div>
        </a>
        <a href="javascript:;" class="weui-cell weui-cell_access viewImage">
            <div class="weui-cell__bd">
                <label class="cl-9999">营业执照信息</label>
            </div>
            <div class="weui-cell__ft">
                <img class="viewPhone business_license_image" data-img="0" src="{$data.business_license_image}" style=" width: 6rem;" alt="{$data.business_license_image}">
                <input class="uploaderInput weui-uploader__input" type="file" accept="image/*" data-field="business_license_image" data-quantity="pic" data-model="shop" data-width="100" data-height="100"/>
                <input type="hidden" name="business_license_image" value="{$data.business_license_image|default=''}">
            </div>
        </a>
        <a href="javascript:;" class="weui-cell weui-cell_access viewImage">
            <div class="weui-cell__bd">
                <label class="cl-9999">经营许可证</label>
            </div>
            <div class="weui-cell__ft">
                <img class="viewPhone business_certificate" data-img="0" src="{$data.business_certificate}" style=" width: 6rem;"  alt="{$data.business_certificate}">
                <input class="uploaderInput weui-uploader__input" type="file" accept="image/*" data-field="business_certificate" data-quantity="pic" data-model="shop" data-width="100" data-height="100"/>
                <input type="hidden" name="business_certificate" value="{$data.business_certificate|default=''}">
            </div>
        </a>
        <a href="{:url('shop_image', ['id' => $data['id']])}" data-target="#camera" class="weui-cell weui-cell_access open-popup">
            <div class="weui-cell__bd">
                <label class="cl-9999">店铺图片</label>
            </div>
            <div class="weui-cell__ft">
                <span class="fs065 cl-3333">查看</span>
            </div>
        </a>
        <a href="{:url('shop_product', ['id' => $data['id']])}" class="weui-cell weui-cell_access">
            <div class="weui-cell__bd">
                <label class="cl-9999">库存管理</label>
            </div>
            <div class="weui-cell__ft">
                <span class="fs065 cl-3333">进入</span>
            </div>
        </a>
        <a href="{:url('replenishment_list', ['id' => $data['id']])}" class="weui-cell weui-cells weui-cell_access">
            <div class="weui-cell__bd">
                <label class="cl-9999">补货申请记录</label>
            </div>
            <div class="weui-cell__ft">
                <span class="fs065 cl-3333">查看</span>
            </div>
        </a>
    </div>
</div>
<!--修改营业项目-->
<div id="businessItem" class="weui-popup__container">
    <div class="weui-popup__overlay"></div>
    <div class="weui-popup__modal">
        <div class="modal-content bg-f5">
            <div class="msui_nav msui_navTop">
                <a class="msui_navTop-back close-popup" href="javascript:;"><i class="micon-back"></i></a>
                <h1 class="msui_navTop-title">营业项目</h1>
                <a href="javascript:;" class="msui_navTop-right businessItem cl-c40">完成</a>
            </div>
            <form id="category_form">
                <div class="js-checkbox">
                    {volist name="data.category_all" id="vo"}
                    <div class="weui-cell">
                        <div class="weui-cell__hd">
                            <input type="checkbox" class="weui-check" name="categorys[]" value="{$vo.id}" {in name="vo.id" value="$data.cate_ids"}checked{/in}>
                            <i class='micon-check-c40 {in name="vo.id" value="$data.cate_ids"}micon-checked-c40{/in}'></i>
                        </div>
                        <div class="weui-cell__bd">
                            <span class="fs065">{$vo.name}</span>
                        </div>
                    </div>
                    {/volist}
                </div>
                <input type="hidden" name="shop_id" value="{$data.id}">
            </form>
        </div>
    </div>
</div>
<!--修改店铺名称-->
<div id="shopName" class="weui-popup__container">
    <div class="weui-popup__overlay"></div>
    <div class="weui-popup__modal">
        <div class="modal-content bg-f5">
            <div class="msui_nav msui_navTop">
                <a class="msui_navTop-back close-popup" href="javascript:;"><i class="micon-back"></i></a>
                <h1 class="msui_navTop-title">营业项目</h1>
                <a href="javascript:;" class="msui_navTop-right edit_shop_name cl-c40">完成</a>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">店铺名称</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" value="{$data.name}" name="shop_name">
                </div>
            </div>
        </div>
    </div>
</div>
{/block}

{block name="javascript"}
{js href="__STATIC__/home/js/jquery.jcrop.min.js" /}
{js href="__STATIC__/home/js/jquery.jcrop.upload.js" /}
{js href="__STATIC__/home/js/exif.js" /}
<script>
    $(function () {
//        经营项目
        $('.businessItem').click(function (e) {
            e.preventDefault();
            var _form = $("#category_form");
            $.ajax({
                type : 'POST',
                url : '{:url("save_category")}',
                data : _form.serialize(),
                dataType : 'json',
                success : function (msg) {
                    if(msg.code == 200) {
                        $.toptip('保存成功！', 'success');
                        window.location.reload();
                    } else {
                        $.toptip(msg.msg);
                    }
                }
            });
        });

        /*
             修改店铺名称
         */
        $(".edit_shop_name").click(function () {
            var _value = $('input[name="shop_name"]').val();
            if (!_value) {
                $.toptip('请输入店铺名称');
                return false;
            }
            save_shop_info('name', _value);
        });

        $('.js-checkbox').on('click','.weui-cell',function () {
            $(this).find('.micon-check-c40').toggleClass('micon-checked-c40')
            $(this).find('input[type="checkbox"]').prop("checked", !$(this).find('input[type="checkbox"]').prop("checked"))
        });
    });

    /**
     * 修改店铺信息
     * @param _field
     * @param _value
     */
    function save_shop_info(_field, _value) {
        $.ajax({
            type : 'POST',
            url : '{:url("save_shop_info")}',
            data : {
                shop_id : '{$data.id}',
                field : _field,
                value : _value
            },
            dataType : 'json',
            success : function (msg) {
                if(msg.code == 200) {
                    $.toptip('保存成功！', 'success');
                    window.location.reload();
                } else {
                    $.toptip(msg.msg);
                }
            }
        });
    }
</script>
{/block}